package cn.myjerry.sort.bubble;

import java.util.Arrays;

/**
 * 冒泡排序最终版
 * @author Jerry
 *
 */

public class bubbleSort3 {
	public static void main(String[] args) {
		int[] arr = {9,1,5,2,4,3};
		boolean exant = true;
		for(int i=0;i<arr.length-1;i++){
			exant = true;
			for(int j=0;j<arr.length-1-i;j++){
				if(arr[j]>arr[j+1]){
					int item = arr[j];
					arr[j] = arr[j+1];
					arr[j+1] = item;
					exant = false;
				}
			}
			if(exant){
				break;
			}
			System.out.println(Arrays.toString(arr));
		}
		System.out.println(Arrays.toString(arr));
	}
}
